<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #app{
            padding: 10vw 5vw 0;
        }
        .top{
            display: flex;
            justify-content: space-between;
        }
        .top input{
            width: 65vw;
            height: 8vw;
            outline: none;
            border: none;
            padding-left: 8vw;
            background: gray;
            border-radius: 4vw;
        }
        .top span{
            color: aqua;
            line-height: 8vw;
        }
        .mid,
        .end{
            display: flex;
            flex-wrap: wrap;
        }
        .mid span{
            padding: 2vw;
            background: grey;
            margin: 2vw;
        }
        .end span{
            padding: 2vw;
            background: grey;
            margin: 2vw;
        }
    </style>
</head>
<body>
    <div id="app">
        <div class="top">
            <input type="text" v-model="ineerText" placeholder="搜索商家、商品名称">
            <span @click="search()">搜索</span>
        </div>
        <h3>历史搜索</h3>
        <div class="mid">
            <span v-for="(item,index) in hSearch">{{item}}</span>
        </div>
        <h3>搜索发现</h3>
        <div class="end">
            <span v-for="(item,index) in sSearch">{{item}}</span>
        </div>
    </div>
</body>
</html>
<script src="../vue-2.5.21.js"></script>
<script>
    var vm = new Vue({
        el:'#app',
        data:{
            ineerText:'',
            hSearch:['天天新鲜'],
            sSearch:['麻辣烫','米线','披萨','蛋糕','汉堡','腊八粥','烤肉拌饭']
        },
        methods:{
            search(){
                if (this.ineerText!='') {
                    this.hSearch.unshift(this.ineerText)
                    this.ineerText = ''
                }
                
            }
        }
    })
</script>